package com.circle.rest.modular.qrtz.listener;

import org.quartz.JobExecutionContext;
import org.quartz.Trigger;
import org.quartz.TriggerListener;

import java.time.LocalDateTime;

/**
 * @program: RestfulApi
 * @description: 触发器监听器
 * @author: 赵航
 * @create: 2019-04-12 17:21
 **/
public class GloballTriggerListener implements TriggerListener {


    @Override
    public String getName() {
        return getClass().getSimpleName();
    }

    @Override
    public void triggerFired(Trigger trigger, JobExecutionContext context) {
//        String triggerName = trigger.getKey().getName();
//        System.out.println("[TRIGGER]" + LocalDateTime.now() + triggerName + " 触发器点火成功 ");
    }

    @Override
    public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) {
//        String triggerName = trigger.getKey().getName();
//        System.out.println("[TRIGGER]" + LocalDateTime.now() + triggerName + " 被否决未被执行");
        return false;
    }

    @Override
    public void triggerMisfired(Trigger trigger) {
//        String triggerName = trigger.getKey().getName();
//        System.out.println("[TRIGGER]" + LocalDateTime.now() + triggerName + " 丢失火种");
    }

    @Override
    public void triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode) {
//        String triggerName = trigger.getKey().getName();
//        System.out.println("[TRIGGER]" + LocalDateTime.now() + triggerName + " 成功执行完毕");
    }
}
